package  
{
	import org.flixel.*;
	import org.flixel.FlxGroup;
	
	public class LevelSection extends FlxGroup
	{
		
		private var _x:int;
		private var _y:int;
		private var _width:int;
		private var _height:int;
		
		public function LevelSection(width:int, height:int, x:int, y:int) 
		{
			_width = width;
			_height = height;
			_x = x;
			_y = y;
			var groundLevelY:int = _height - ConfigData.GROUND_HEIGHT;
			
			var ground:FlxTileblock = new FlxTileblock( x, y + groundLevelY, _width, ConfigData.GROUND_HEIGHT);
			ground.loadTiles(AssetManager.Ground, 20, 60);
			this.add(ground);
			
			var obstacle:FlxTileblock = new FlxTileblock( x + _width / 4, y + groundLevelY - 20, 50, 20);
			obstacle.loadTiles(AssetManager.Ground, 20, 20);
			this.add(obstacle);
		}
		
		public function set alpha(a:Number):void
		{
			for (var i:int = 0; i <this.length; i++)
			{
				if (this.members[i] != null)
				{
					this.members[i].alpha = a;
				}
			}
		}
		
		public function set x(xVal:int):void
		{
			var xDif:int = xVal - _x;
			for (var i:int = 0; i <this.length; i++)
			{
				this.members[i].x += xDif;
			}
			_x = xVal;
		}
		
		public function get x():int
		{
			return _x;
		}
		
		public function set y(yVal:int):void
		{
			var yDif:int = yVal - _y;
			for (var i:int = 0; i <this.length; i++)
			{
				this.members[i].y += yDif;
			}
			_y = yVal;
		}
		
		public function get y():int
		{
			return _y;
		}
		
		public function get width():int
		{
			return _width;
		}
		
		public function get height():int
		{
			return _height;
		}
		
		public function setColor(color:int):void
		{
			for (var i:int = 0; i <this.length; i++)
			{
				this.members[i].color = color;
			}
		}
		
	}

}